
package com.dream.model.base;

import org.hibernate.transform.BasicTransformerAdapter;

/**
 * 
 * @author Evan
 * @date 2013-8-25
 * 
 */
public class CodeVOTransformer extends BasicTransformerAdapter {

	private  static final CodeVOTransformer instance = new CodeVOTransformer();

	public static CodeVOTransformer newInstance() {
		return CodeVOTransformer.instance;
	}

	private static final long serialVersionUID = -2564187615698857515L;

	@Override
	public Object transformTuple(Object[] tuple, String[] aliases) {

		CodeVO vo = new CodeVO();
		if(aliases != null){
			int i=0;
			for (Object value : tuple) {
				String alias = aliases[i];
				if ((alias.equalsIgnoreCase("id"))) {
					vo.setId(value);
				}
				if ((alias.equalsIgnoreCase("name"))) {
					vo.setName(value);
				}
				if ((alias.equalsIgnoreCase("comment"))) {
					vo.setComment(value);
				}
				if ((alias.equalsIgnoreCase("extensionA"))) {
					vo.setExtensionA(value);
				}
				if ((alias.equalsIgnoreCase("extensionB"))) {
					vo.setExtensionB(value);
				}
				if ((alias.equalsIgnoreCase("extensionC"))) {
					vo.setExtensionC(value);
				}
				i++;
			}
		}
		return vo;
	}


}
